<template>
  <MyMavonEditor @publish="publish" operateType="publish" ref="my-mavon-editor" class="create-article" />
</template>

<script>
import { GET_TAG_TREE, GET_FUNCTIONALITIES, SAVE_USER_INFO } from '__STORE__/operation-type'
import { publishArticle } from '__SERVICE__/article.js'
import MyMavonEditor from '__COMPONENTS__/mavon_editor/MyMavonEditor.vue'
export default {
  name: 'CreateArticle',
  components: { MyMavonEditor },
  mounted() {
    const {'my-mavon-editor': myMavonEditor}= this.$refs
  },
  methods: {
    //真正做的事情
    async publish(data) {
      const result = await publishArticle(Object.assign({}, data))
      this.$store.dispatch(SAVE_USER_INFO, {
        access_token: result.data.access_token
      })
      this.$Notice.success({
        title: '操作成功', desc: '修改成功', duration: 3000
      })
      this.$router.push({name: 'Mine'})
    }
  }
}
</script>

<style>

</style>